package com.logindemo.dao.impl;

import com.logindemo.dao.UserDao;
import com.logindemo.entity.User;

import java.util.List;

/**
 * @author wzm
 * @create 2023-03-07 10:32
 */
public class UserDaoImpl extends BaseDao implements UserDao {
    @Override
    public User selectByNameAndPwd(User user) {
        String sql = "select * from user where username = ? and password = ?";
        return selectForOne(User.class,sql,user.getUsername(),user.getPassword());
    }

    @Override
    public Integer insertUser(User user) {
        String sql = "insert into user values(?,?,?)";
        return update(sql,0,user.getUsername(),user.getPassword());
    }

    @Override
    public List<User> selectByName(User user) {
        String sql = "select * from user where username like ?";
        return selectForList(User.class,sql,"%"+user.getUsername()+"%");
    }
}
